/*
 * This file is part of the OSMembrane project.
 * More informations under www.osmembrane.de
 * 
 * The project is licensed under the GNU GENERAL PUBLIC LICENSE 3.0.
 * for more details about the license see http://www.osmembrane.de/license/
 * 
 * Source: $HeadURL: http://osmembrane-gui.googlecode.com/svn/sources/src/de/osmembrane/model/parser/ParserFactory.java $ ($Revision: 821 $)
 * Last changed: $Date: 2011-02-15 14:54:41 +0000 (Tue, 15 Feb 2011) $
 */



package de.osmembrane.model.parser;

/**
 * Factory for Parser-Instances.
 * 
 * @author jakob_jarosch
 */
public class ParserFactory {

	/**
	 * Implements the Singleton pattern.
	 */
	private static ParserFactory instance = new ParserFactory();

	/**
	 * Initiates the ModelProxy.
	 */
	private ParserFactory() {

	}

	/**
	 * Getter for the Singleton pattern.
	 * 
	 * @return the one and only instance of ParserFactory
	 */
	public static ParserFactory getInstance() {
		return instance;
	}

	/**
	 * Returns a given parser-Class as a instance.
	 * 
	 * @param clazz
	 *            which should be created
	 */
	public IParser getParser(Class<? extends IParser> clazz) {
		try {
			return clazz.newInstance();
		} catch (InstantiationException e) {
			/* should not happen */
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			/* should not happen */
			e.printStackTrace();
		}

		return null;
	}
}
